package web;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.zhuozhengsoft.pageoffice.DocumentOpenType;
import com.zhuozhengsoft.pageoffice.FileMakerCtrl;
import com.zhuozhengsoft.pageoffice.OpenModeType;
import com.zhuozhengsoft.pageoffice.PageOfficeCtrl;
import com.zhuozhengsoft.pageoffice.wordwriter.WordDocument;

@Controller
public class FileMakerPDF extends HttpServlet{
	private static final long serialVersionUID = -758686623642845302L;
	
	@RequestMapping("fileMakerPDF")  
    public String fileMakerPDF(HttpServletRequest request, HttpServletResponse response){
		FileMakerCtrl fmCtrl = new FileMakerCtrl(request);
		fmCtrl.setServerPage(request.getContextPath()+"/poserver.zz");
		WordDocument doc = new WordDocument();
		//禁用右击事件
		doc.setDisableWindowRightClick(true);
		//给数据区域赋值，即把数据填充到模板中相应的位置
		doc.openDataRegion("PO_company").setValue("北京卓正志远软件有限公司  ");
		fmCtrl.setSaveFilePage("savefile.do");
		fmCtrl.setWriter(doc);
		fmCtrl.setJsFunction_OnProgressComplete("OnProgressComplete()");
		fmCtrl.fillDocumentAsPDF("doc/template.doc", DocumentOpenType.Word, "aaa.pdf");
		fmCtrl.setTagId("FileMakerCtrl1");
		return "FileMakerPDF";
    } 
}
